package com.example.demo.constent;

import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

@Component
public class RequestContext {
    private static ThreadLocal<HttpServletRequest> currentRequest = new ThreadLocal<>();

    public static void setCurrentRequest(HttpServletRequest request) {
        currentRequest.set(request);
    }

    public static HttpServletRequest getCurrentRequest() {
        return currentRequest.get();
    }

    public static void clearCurrentRequest() {
        currentRequest.remove();
    }
}
